using System;
using DevExpress.Xpo;
using SmartPeople.Framework.Security.Providers.XPO;
using SmartPeople.Framework.SecuritySpace;

namespace SmartPeople.Framework.Security.Providers.XPO
{
    [Persistent("SecuredTypeStates")]
    internal class XPSecuritySecuredTypeState : XPCustomObject, ISecuritySecuredTypeState
    {
        public XPSecuritySecuredTypeState()
        {
            // Use this constructor when you want to create a new object.
            // Place here your initialization code.
        }

        public XPSecuritySecuredTypeState(Session session) : base(session)
        {
            // This constructor is used when an object is loaded from a persistent storage.
            // Do not place any code here.
        }

        #region Fields

               
        [Key(AutoGenerate = true)]
        [Persistent("GID")]
        private Guid gID;

        [Persistent("Name")]
        private string name; 

        #endregion

        #region Property

        [NonPersistent]
        public Guid GID
        {
            get { return gID; }
            set
            {
                if (gID != value)
                {
                    Guid OldValue = gID;
                    gID = value;
                    OnChanged("GID", OldValue, value);
                }
            }
        }


        [NonPersistent]
        public string Name
        {
            get { return name; }
            //set { name = value; }
            set
            {
                if (name != value)
                {
                    string OldValue = name;
                    name = value;
                    OnChanged("Name", OldValue, value);
                }
            }
        } 
        #endregion

        [Persistent("SecuredType"), Association("SecuredTypeStates", UseAssociationNameAsIntermediateTableName = true)]
        internal XPSecuritySecuredType securedDocument;
    }
}